package org.jeecg.glr.service.impl;

import org.jeecg.glr.entity.GlrRadioTaskMember;
import org.jeecg.glr.mapper.GlrRadioTaskMemberMapper;
import org.jeecg.glr.service.IGlrRadioTaskMemberService;
import org.jeecg.glr.util.StringUtil;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: 任务关联信息
 * @Author: jeecg-boot
 * @Date:   2020-02-14
 * @Version: V1.0
 */
@Service
public class GlrRadioTaskMemberServiceImpl extends ServiceImpl<GlrRadioTaskMemberMapper, GlrRadioTaskMember> implements IGlrRadioTaskMemberService {

    @Resource GlrRadioTaskMemberMapper glrRadioTaskMemberMapper;


    @Override
    public boolean bingRadio(GlrRadioTaskMember domain) {
        if(StringUtil.isNotEmpty(domain.getIds())){
            String [] ids=domain.getIds().split(",");
            for(int i=0;i<ids.length;i++){
                if(StringUtil.isNotEmpty(ids[i])){
                    GlrRadioTaskMember r = new GlrRadioTaskMember();
                    r.setMemberId(ids[i]);
                    r.setMemberType("1");
                    r.setTaskId(domain.getTaskId());
                    super.save(r);
                }
            }
        }
        return true;
    }

    @Override
    public List<String> getRadioByTaskId(String taskId) {
        return glrRadioTaskMemberMapper.getRadioByTaskId(taskId);
    }

    @Override
    public List<String> getResourceByTaskId(String taskId) {
        return glrRadioTaskMemberMapper.getResourceByTaskId(taskId);
    }

    @Override
    public boolean bingResource(GlrRadioTaskMember domain) {
        if(StringUtil.isNotEmpty(domain.getIds())){
            String [] ids=domain.getIds().split(",");
            for(int i=0;i<ids.length;i++){
                if(StringUtil.isNotEmpty(ids[i])){
                    GlrRadioTaskMember r = new GlrRadioTaskMember();
                    r.setMemberId(ids[i]);
                    r.setMemberType("2");
                    r.setTaskId(domain.getTaskId());
                    super.save(r);
                }
            }
        }
        return true;
    }
}
